from django.db import models


# Create your models here.

# 设计一个主机管理系统，用于管理企业内部的主机，包含主机、城市、机房等模型

class CityModel(models.Model):
    name = models.CharField(max_length=255, verbose_name='城市名称')

    class Meta:
        db_table = 'tb_city_model'
        verbose_name = '城市表'
        verbose_name_plural = verbose_name


class MachineRoomModel(models.Model):
    city = models.ForeignKey(to=CityModel, verbose_name='城市', on_delete=models.CASCADE)

    class Meta:
        db_table = 'tb_machine_room_model'
        verbose_name = '机房表'
        verbose_name_plural = verbose_name


class HostModel(models.Model):
    machine_room = models.ForeignKey(to=MachineRoomModel, verbose_name='机房', on_delete=models.CASCADE)
    password = models.CharField(max_length=255, verbose_name='root密码')
    ip = models.CharField(max_length=16, verbose_name='ip地址')
    cpu = models.IntegerField(verbose_name='CPU')
    memory = models.IntegerField(verbose_name='内存')
    motherboard_choices = (
        (0, 'ATX'),
        (1, 'MicroATX'),
        (2, 'Mini-ITX'),
    )
    motherboard = models.IntegerField(verbose_name='主板', choices=motherboard_choices)
    hard_disk = models.IntegerField(verbose_name='硬盘大小', help_text='硬盘大小，单位为G')
    state_choices = (
        (0, '未使用'),
        (1, '使用中'),
        (2, '已报废')
    )
    is_use = models.IntegerField(verbose_name='状态', choices=state_choices)

    class Meta:
        db_table = 'tb_host_model'
        verbose_name = '主机表'
        verbose_name_plural = verbose_name


class StatisticsModel(models.Model):
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='统计时间')
    machine_room = models.IntegerField(verbose_name='机房')
    number = models.IntegerField(verbose_name='主机数量')

    class Meta:
        db_table = 'tb_statistics_model'
        verbose_name = '机房统计表'
        verbose_name_plural = verbose_name
